SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

create procedure dbo.DnnProduct_GetSiteLog3

	@PortalID int,
	@PortalAlias nvarchar(50),
	@StartDate datetime,
	@EndDate datetime

as

select 'Name' = dbo.DnnProduct_Users.FirstName + ' ' + dbo.DnnProduct_Users.LastName,
	'Requests' = count(*),
	'LastRequest' = max(DateTime)
from dbo.DnnProduct_SiteLog
inner join dbo.DnnProduct_Users on dbo.DnnProduct_SiteLog.UserId = dbo.DnnProduct_Users.UserId
where dbo.DnnProduct_SiteLog.PortalId = @PortalID
and dbo.DnnProduct_SiteLog.DateTime between @StartDate and @EndDate
and dbo.DnnProduct_SiteLog.UserId is not null
group by dbo.DnnProduct_Users.FirstName + ' ' + dbo.DnnProduct_Users.LastName
order by Requests desc









GO
